import provagrails.Course
import provagrails.Argument
import provagrails.Thread
class BootStrap {

    def init = { servletContext ->

        //definisco i corsi
        def algoritmiCourse=new Course(name: "Algoritmi 2012").save(failOnError: true)
        def enterpriseCourse=new Course(name: "Applicazioni Enterprise").save(failOnError: true)
        def ricercaOperativaCourse=new Course(name: "Ricerca Operativa").save(failOnError: true)

        //definisco gli argomenti
        def modelbuildingArgument=new Argument(name: "Model Building",course: ricercaOperativaCourse).save(failOnError: true)
        def simplexArgument=new Argument(name: "Simplex",course: ricercaOperativaCourse).save(failOnError: true)
        def branchboundArgument=new Argument(name: "Branch and Bound",course: ricercaOperativaCourse).save(failOnError: true)
        def complessitaArgument=new Argument(name: "Complessità",course: algoritmiCourse).save(failOnError: true)
        def macchinaturingArgument=new Argument(name:"Macchina Turing",course: algoritmiCourse).save(failOnError: true)
        def groovyArgument=new Argument(name: "Groovy",course: enterpriseCourse).save(failOnError: true)
        def grailsArgument=new Argument(name: "Grails",course: enterpriseCourse).save(failOnError: true)
        def domainmodelArgument=new Argument(name:"Domain Model",course: enterpriseCourse).save(failOnError: true)

        //definisco le threads
        def thread1=new Thread(name: "Thread1",text:"descrizione della thread",argument:modelbuildingArgument).save(failOnError: true)
        def thread2=new Thread(name: "Thread2",text:"descrizione della thread",argument:simplexArgument).save(failOnError: true)
        def thread3=new Thread(name: "Thread3",text:"descrizione della thread",argument:branchboundArgument).save(failOnError: true)
        def thread4=new Thread(name: "Thread4",text:"descrizione della thread",argument:complessitaArgument).save(failOnError: true)
        def thread5=new Thread(name: "Thread5",text:"descrizione della thread",argument:macchinaturingArgument).save(failOnError: true)
        def thread6=new Thread(name: "Thread6",text:"descrizione della thread",argument:groovyArgument).save(failOnError: true)
        def thread7=new Thread(name: "Thread7",text:"descrizione della thread",argument:grailsArgument).save(failOnError: true)
        def thread8=new Thread(name: "Thread8",text:"descrizione della thread",argument:domainmodelArgument).save(failOnError: true)
        def thread9=new Thread(name: "Thread9",text:"descrizione della thread",argument:domainmodelArgument).save(failOnError: true)








    }
    def destroy = {
    }
}
